package com.fz.us.admin.company.entity;

import com.fz.us.admin.base.bean.BaseEnumManager;

import javax.persistence.*;
import java.util.Date;
import java.util.Set;

/**
 * 实体类 - 用户
 * ============================================================================
 * 版权所有 2016 。
 *
 * @author fallenpanda
 * @version 1.0 2016-07-25 。
 * ============================================================================
 */
@Entity
@Table(name="sys_user")
public class User extends CompanyEntity {

    private static final long serialVersionUID = 4302932977726397247L;

    /**
     * 账号信息
     */
    private String adminId;
    /**
     * 性别（0女 1男）
     */
    private BaseEnumManager.SexEnum sex;
    /**
     * 生日
     */
    private Date birthday;
    /**
     * 省
     */
    private String province;
    /**
     * 市
     */
    private String city;
    /**
     * 区
     */
    private String county;
    /**
     * 家庭住址
     */
    private String address;

    /**
     * 职责
     */
    private Set<Duty> dutySet;
    /**
     * 群组
     */
    private Set<Group> groupSet;

    public String getAdminId() {
        return adminId;
    }

    public void setAdminId(String adminId) {
        this.adminId = adminId;
    }

    @Enumerated(EnumType.STRING)
    public BaseEnumManager.SexEnum getSex() {
        return sex;
    }

    public void setSex(BaseEnumManager.SexEnum sex) {
        this.sex = sex;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getCounty() {
        return county;
    }

    public void setCounty(String county) {
        this.county = county;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    @ManyToMany(cascade = {CascadeType.ALL},fetch = FetchType.LAZY, mappedBy = "usersSet")
    @OrderBy("name asc")
    public Set<Group> getGroupSet() {
        return groupSet;
    }

    public void setGroupSet(Set<Group> groupSet) {
        this.groupSet = groupSet;
    }

    @OneToMany(mappedBy = "user", fetch = FetchType.LAZY)
    @OrderBy("id asc")
    public Set<Duty> getDutySet() {
        return dutySet;
    }

    public void setDutySet(Set<Duty> dutySet) {
        this.dutySet = dutySet;
    }



}
